//
//  CinemaTableViewCell.m
//  豆瓣3
//
//  Created by you on 15/10/23.
//  Copyright © 2015年 yym. All rights reserved.
//

#import "CinemaTableViewCell.h"
#import "CallButton.h"
@implementation CinemaTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self p_setView];
    }
    return self;
}

- (void)p_setView
{
    
    self.imv = [[UIImageView alloc] init];
    self.imv.frame = CGRectMake(5, 5, 360, 130);
    self.imv.image = [UIImage imageNamed:@"bg_eventlistcell.png"];
    [self.contentView addSubview:self.imv];
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.font = [UIFont systemFontOfSize:20];
//    self.nameLabel.backgroundColor = [UIColor cyanColor];
//    self.nameLabel.text = @"北京博纳影城朝阳门旗舰店";
    self.nameLabel.frame = CGRectMake(5, 5, 350, 20);
    [self.imv addSubview:self.nameLabel];
    
    self.addressLabel = [[UILabel alloc] init];
//    self.addressLabel.backgroundColor = [UIColor redColor];
//    self.addressLabel.text = @"sadadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasdaadasda";
    self.addressLabel.numberOfLines = 0;
    self.addressLabel.frame = CGRectMake(5, CGRectGetMaxY(self.nameLabel.frame) + 5, 350, 70);
    [self.imv addSubview:self.addressLabel];
    
    self.callButton = [CallButton buttonWithType:UIButtonTypeSystem];
    self.callButton.frame = CGRectMake(10, CGRectGetMaxY(self.addressLabel.frame) + 10, 20, 20);
//    self.callButton.backgroundColor = [UIColor cyanColor];
    [self.callButton setBackgroundImage:[UIImage imageNamed:@"phone.png"] forState:(UIControlStateNormal)];
    [self.contentView addSubview:self.callButton];
    
    self.phoneLabel = [[UILabel alloc] init];
//    self.phoneLabel.backgroundColor = [UIColor greenColor];
//    self.phoneLabel.text = @"110";
    self.phoneLabel.frame = CGRectMake(CGRectGetMaxX(self.callButton.frame) + 10, CGRectGetMinY(self.callButton.frame), 250, 20);
    [self.contentView addSubview:self.phoneLabel];
    
    self.mapButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    self.mapButton.frame = CGRectMake(CGRectGetMaxX(self.frame) - 30, CGRectGetMinY(self.phoneLabel.frame), 17, 17);
    [self.mapButton setBackgroundImage:[UIImage imageNamed:@"cinema.png"] forState:(UIControlStateNormal)];
    [self.mapButton addTarget:self action:@selector(mapButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    [self.contentView addSubview:self.mapButton];
    
    
    
    [self.callButton addTarget:self action:@selector(callButtonAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    
}

- (void)callButtonAction:(CallButton *)sender
{
   
        
        if (self.delegate != nil && [self.delegate respondsToSelector:@selector(callButton:)]) {
            [self.delegate callButton:sender];
        }

}

-(void)mapButtonAction:(UIButton *)sender
{
    NSLog(@"打开地图");
}


//- (void)layoutSubviews
//{
//    [super layoutSubviews];
//    
//    
//    self.nameLabel.frame = CGRectMake(10, 10, 350, 50);
//    
//    self.addressLabel.frame = CGRectMake(10, CGRectGetMaxY(self.nameLabel.frame) + 10, 350, 80);
//    
//    self.phoneLabel.frame = CGRectMake(10, CGRectGetMaxY(self.addressLabel.frame) + 10, 350, 50);
//}

+ (CGFloat)cellHeight
{
    return 150;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
